//
//  ActivityIndicatorViewStyle.swift
//  EasyCoding
//
//  Created by JY_NEW on 2020/6/17.
//

import UIKit

extension UCSetting where TargetType: UIActivityIndicatorView {
    ///菊花样式
    public static func style(_ style:UIActivityIndicatorView.Style) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.style = style
        })
    }
    ///菊花颜色
    public static func color(_ color:UIColor) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.color = color
        })
    }
    ///是否停止时自动隐藏
    public static func autoHide(_ hidesWhenStopped:Bool = true) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.hidesWhenStopped = hidesWhenStopped
        })
    }
    ///调用启动动画方法，需要保持启动时可直接设置
    public static func start() -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.startAnimating()
        })
    }
    ///理论上放在这里没什么用，不会在创建的时候调用stop
    public static func stop() -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.stopAnimating()
        })
    }
}
